package cn.biplam.common.wrapper.tree;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 树型结构节点的基本数据类
 * @author XiaoRuxing 2009-5-20上午10:38:13
 * @version 1.0
 */
public class TreeNode implements Serializable{

	/** */
	private static final long serialVersionUID = -3293327623439832931L;
	/** 节点ID */
	private String nodeID;
	/** 父节点ID */
	private String parent;
	/** 节点名称 */
	private String nodeName;
	/** 节点描述 */
	private String nodeDesc;
	/** 节点序号 */
	private String sequence;
	/** 节点操作 */
	private String operator;
	/** 索引表节点对应的物理表中的记录ID */
	private String nodeCode;
	/** 节点层级 */
	private String level;
	/** 是否根节点 */
	private String isRoot;
	/** 是否叶子节点 */
	private String isLeaf;
	/** 是否有哥哥节点 */
	private String haveBrother;
	/** 是否有弟弟节点 */
	private String haveLBrother;
	/** 节点类型 */
	private String nodeType;
	/** 所有父节点是否有兄弟标示 */
	private ArrayList<String> parentSibling;
	
	public TreeNode(){}
	
	/**
	 * 传入节点ID，父节点ID和节点名称创建树节点数据类
	 * @param nodeID   节点ＩＤ
	 * @param parent　　父节点ＩＤ
	 * @param nodeName　节点名称
	 */
	public TreeNode(String nodeID,String parent,String nodeName){
		this(nodeID,parent,nodeName,null,null,null);
	}
	
	/**
	 * 传入节点id、父节点ID、节点名称、节点描述、节点编号和节点操作符号创建树节点数据类
	 * @param nodeID    节点ID
	 * @param parent    父节点ID
	 * @param nodeName  节点名称
	 * @param nodeDesc  节点描述
	 * @param nodeCode  节点编号
	 * @param operator  节点操作符
	 */
	public TreeNode(String nodeID,String parent,String nodeName,String nodeDesc,String nodeCode,String operator){
		setNodeID(nodeID);
		setParent(parent);
		setNodeName(nodeName);
		setNodeCode(nodeCode);
		setNodeDesc(nodeDesc);
		setOperator(operator);
	}
	
	public String getNodeID() {
		return nodeID;
	}
	public void setNodeID(String nodeID) {
		this.nodeID = nodeID;
	}
	public String getParent() {
		return parent;
	}
	public void setParent(String parent) {
		this.parent = parent;
	}
	public String getNodeName() {
		return nodeName;
	}
	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}
	public String getNodeDesc() {
		return nodeDesc;
	}
	public void setNodeDesc(String nodeDesc) {
		this.nodeDesc = nodeDesc;
	}
	public String getSequence() {
		return sequence;
	}
	public void setSequence(String sequence) {
		this.sequence = sequence;
	}
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public String getNodeCode() {
		return nodeCode;
	}
	public void setNodeCode(String nodeCode) {
		this.nodeCode = nodeCode;
	}

	public String getIsRoot() {
		return isRoot;
	}

	public void setIsRoot(String isRoot) {
		this.isRoot = isRoot;
	}

	public String getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(String isLeaf) {
		this.isLeaf = isLeaf;
	}

	public String getHaveBrother() {
		return haveBrother;
	}

	public void setHaveBrother(String haveBrother) {
		this.haveBrother = haveBrother;
	}

	public String getHaveLBrother() {
		return haveLBrother;
	}

	public void setHaveLBrother(String haveLBrother) {
		this.haveLBrother = haveLBrother;
	}

	public ArrayList<String> getParentSibling() {
		return parentSibling;
	}

	public void setParentSibling(ArrayList<String> getParentSibling) {
		this.parentSibling = getParentSibling;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}
	
	public String getNodeType() {
		return nodeType;
	}

	public void setNodeType(String nodeType) {
		this.nodeType = nodeType;
	}

	/**
	 * 获取数据的数组表示形式
	 * @return 
	 */
	public String[] getStingArray(){
		ArrayList<String> treeNode=new ArrayList<String>();
		treeNode.add(this.nodeID);
		treeNode.add(this.parent);
		treeNode.add(this.nodeName);
		treeNode.add(this.level);
		treeNode.add(this.isLeaf);
		treeNode.add(this.sequence);
		treeNode.add(this.haveBrother);
		treeNode.add(this.haveLBrother);
		treeNode.add(this.operator);
		treeNode.add(this.nodeDesc);
		treeNode.add(this.nodeCode);
		treeNode.add(this.isRoot);
		treeNode.add(this.nodeType);
		if(this.parentSibling!=null){
			treeNode.addAll(this.parentSibling);
		}
		String[] str=new String[treeNode.size()];
		for(int i=0;i<treeNode.size();i++){
			str[i]=treeNode.get(i);
		}
		return str;
	}
	
	/**
	 * 获取当前数据节点是否与指定节点相等
	 * @param compareNode 比较节点
	 * @return 当前数据节点是否与指定节点相等
	 */
	public boolean equals(TreeNode compareNode){
		return this.nodeID.equals(compareNode.getNodeID());
	}
}
